package com.muaz;

import java.io.File;

import android.os.FileObserver;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

public  class Pemantau extends FileObserver {
	public HantarSMS mHantarSMS;
	public Handler mHandler;
	public Runnable sendSmsRunnable;
	public Pemantau(String path, HantarSMS mainActivity) {
		super(path);
		mHantarSMS = mainActivity;
		mHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
			super.handleMessage(msg);
			}
		};
		sendSmsRunnable = new Runnable() {
	        public void run() {
	        	Log.i(" - OBSERVER --","");
	        	mHantarSMS.updateIsiSms();
	        	mHantarSMS.loadDataToTextFields();
				mHantarSMS.sendSMS();
				mHantarSMS.deleteDataFile();
				Log.i(" - PERHATIAN --","File changed, sms sent");
	        }
		};

	}
	
	 public void onEvent(int event, String path) {
		 switch (event) {
		 case CREATE:
			 mHandler.post(sendSmsRunnable);
			break;
		 }
        }
}     



